﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace UMLDesigner.Widgets
{
    enum SlotManagerType
    {
        HORIZONTAL,
        VERTICAL
    }

    public class SlotManager
    {
        public SlotManager(Point location, Size size)
        {
            leftSlots = new VerticalSlotList(new Point(location.X, location.Y), size.Height);
            rightSlots = new VerticalSlotList(new Point(location.X + size.Width, location.Y), size.Height);
            topSlots = new HorizontalSlotList(new Point(location.X, location.Y), size.Width);
            bottomSlots = new HorizontalSlotList(new Point(location.X, location.Y + size.Height), size.Width);
        }

        private enum WidgetSide
        {
            LEFT,
            TOP,
            BOTTOM,
            RIGHT
        }

        private WidgetSide GetWidgetSide(Point source, Point destination)
        {
            if (Math.Abs(source.X - destination.X) > Math.Abs(source.Y - destination.Y))
            {
                // The connector will connect to one of the sides.
                if (source.X < destination.X)
                {
                    return WidgetSide.RIGHT;
                }
                else
                {
                    return WidgetSide.LEFT;
                }
            }
            else
            {
                // The connector will be on the top or bottom.
                if (source.Y > destination.Y)
                {
                    return WidgetSide.TOP;
                }
                else
                {
                    return WidgetSide.BOTTOM;
                }
            }
        }

        private SlotList leftSlots;
        private SlotList rightSlots;
        private SlotList topSlots;
        private SlotList bottomSlots;
    }
}
